package com.example.tutorial.java.concurrent.thread;

/**
 * @author: cph
 * @date: 2022-5-3
 */
public class ThreadJoinTest {

    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            for (int i = 0; i < 1000000; i++) {
                System.out.println(i);
            }
        });
        t.start();

        // main线程阻塞至t线程执行完任务
        t.join();

        // t线程执行完线程任务后才执行下面的代码
        System.out.println("isInterrupted: " + t.isInterrupted());
        System.out.println("isAlive: " + t.isAlive());
    }
}
